import { axios } from '@/utils/request'
import QS from 'qs'

const api = {
  user: '/system/user',
  role: '/system/role',
  permission: '/system/menu',
  dept: '/system/dept',
  dictType: '/system/dict/type',
  dictData: '/system/dict/data',
  dist: '/system/districts',
  config: '/system/config',
  oss: '/system/oss',
  sysBusinessInfo: '/system/sysBusinessInfo',
  sysDealerInfo: '/system/sysDealerInfo',
  sysDcarbrandClassifyConfig: '/system/sysDcarbrandClassifyConfig',
  sysInsuranceSchemeConfig: '/system/sysInsuranceSchemeConfig',
  sysInsuranceDetails: '/system/sysInsuranceDetails',
  sysInsuranceweekDetails: '/system/sysInsuranceweekDetails'
}

export default api

// user
export function getUserList (parameter) {
  return axios({
    url: api.user + '/list',
    method: 'get',
    params: parameter
  })
}

export function getUser (userId) {
  return axios({
    url: api.user + '/get/' + `${userId}`,
    method: 'get'
  })
}
export function saveUser (parameter) {
  return axios({
    url: api.user + (parameter.userId > 0 ? '/update' : '/save'),
    method: 'post',
    data: parameter,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}
export function delUser (parameter) {
  return axios({
    url: api.user + '/remove',
    method: 'post',
    params: parameter
  })
}
export function changUserStatus (parameter) {
  return axios({
    url: api.user + '/status',
    method: 'post',
    data: parameter
  })
}
export function resetPwd (parameter) {
  return axios({
    url: api.user + '/resetPwd',
    method: 'post',
    data: parameter
  })
}

// role
export function getRoleList (parameter) {
  return axios({
    url: api.role + '/list',
    method: 'get',
    params: parameter
  })
}
export function getRoleAll () {
  return axios({
    url: api.role + '/all',
    method: 'get'
  })
}

export function saveRole (parameter) {
  return axios({
    url: api.role + (parameter.roleId > 0 ? '/update' : '/save'),
    method: 'post',
    data: parameter,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

export function delRole (parameter) {
  return axios({
    url: api.role + '/remove',
    method: 'post',
    params: parameter
  })
}
export function changRoleStatus (parameter) {
  return axios({
    url: api.role + '/status',
    method: 'post',
    data: parameter
  })
}
export function authDataScope (parameter) {
  return axios({
    url: api.role + '/authDataScope',
    method: 'post',
    data: parameter
  })
}

// menu
export function getPermissionAll (parameter) {
  return axios({
    url: api.permission + '/all',
    method: 'get',
    params: parameter
  })
}
export function getPermissions (parameter) {
  return axios({
    url: api.permission + '/list',
    method: 'get',
    params: parameter
  })
}
export function getRolePermIds (roleId) {
  return axios({
    url: api.permission + '/role/' + `${roleId}`,
    method: 'get'
  })
}

export function savePerm (parameter) {
  return axios({
    url: api.permission + (parameter.menuId > 0 ? '/update' : '/save'),
    method: 'post',
    data: parameter,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

export function delPerm (deptId) {
  return axios({
    url: api.permission + '/remove/' + `${deptId}`,
    method: 'post'
  })
}

// dept
export function getDeptList (parameter) {
  return axios({
    url: api.dept + '/list',
    method: 'get',
    params: parameter
  })
}
export function getDeptListEnable (parameter) {
  return axios({
    url: api.dept + '/list/enable',
    method: 'get',
    params: parameter
  })
}
export function getRoleDeptIds (roleId) {
  return axios({
    url: api.dept + '/role/' + `${roleId}`,
    method: 'get'
  })
}
export function saveDept (parameter) {
  return axios({
    url: api.dept + (parameter.deptId > 0 ? '/update' : '/save'),
    method: 'post',
    data: parameter,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

export function delDept (deptId) {
  return axios({
    url: api.dept + '/remove/' + `${deptId}`,
    method: 'post'
  })
}
// dictType
export function getDictTypeList (parameter) {
  return axios({
    url: api.dictType + '/list',
    method: 'get',
    params: parameter
  })
}
export function saveDictType (parameter) {
  return axios({
    url: api.dictType + (parameter.dictId > 0 ? '/update' : '/save'),
    method: 'post',
    data: parameter,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}
export function delDictType (parameter) {
  return axios({
    url: api.dictType + '/remove',
    method: 'post',
    params: parameter
  })
}

// dictData
export function getDictDataList (parameter) {
  return axios({
    url: api.dictData + '/list',
    method: 'get',
    params: parameter
  })
}
export function saveDictData (parameter) {
  return axios({
    url: api.dictData + (parameter.dictCode > 0 ? '/update' : '/save'),
    method: 'post',
    data: parameter,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}
export function delDictData (parameter) {
  return axios({
    url: api.dictData + '/remove',
    method: 'post',
    params: parameter
  })
}
// dist 地区
export function getDistList (parameter) {
  return axios({
    url: api.dist + '/list',
    method: 'get',
    params: parameter
  })
}
export function saveDist (parameter) {
  return axios({
    url: api.dist + (parameter.id > 0 ? '/update' : '/save'),
    method: 'post',
    data: parameter,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}
export function delDist (parameter) {
  return axios({
    url: api.dist + '/remove',
    method: 'post',
    params: parameter
  })
}
// config 配置
export function getConfigList (parameter) {
  return axios({
    url: api.config + '/list',
    method: 'get',
    params: parameter
  })
}
export function saveConfig (parameter) {
  return axios({
    url: api.config + (parameter.configId > 0 ? '/update' : '/save'),
    method: 'post',
    data: parameter,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}
export function delConfig (parameter) {
  return axios({
    url: api.config + '/remove',
    method: 'post',
    params: parameter
  })
}
// oss
export function getOssList (parameter) {
  return axios({
    url: api.oss + '/list',
    method: 'get',
    params: parameter
  })
}
export function saveOss (parameter) {
  return axios({
    url: api.oss + (parameter.id > 0 ? '/update' : '/save'),
    method: 'post',
    data: parameter,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}
export function delOss (parameter) {
  return axios({
    url: api.oss + '/remove',
    method: 'post',
    params: parameter
  })
}
export function getOssConfig () {
  return axios({
    url: api.oss + '/config',
    method: 'get'
  })
}
export function saveOssConfig (parameter) {
  return axios({
    url: api.oss + '/saveConfig',
    method: 'post',
    params: parameter
  })
}
// sysBusinessInfo
export function getSysBusinessInfoList (parameter) {
  return axios({
    url: api.sysBusinessInfo + '/list',
    method: 'get',
    params: parameter
  })
}
export function saveSysBusinessInfo (parameter) {
  console.log(parameter, parameter.id > 0, '------<<>>>>')
  return axios({
    url: api.sysBusinessInfo + (parameter.id > 0 ? '/update' : '/save'),
    method: 'post',
    data: parameter,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}
export function insertOrderId (parameter) {
  return axios({
    url: api.sysBusinessInfo + '/insertOrderId',
    method: 'post',
    data: parameter,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}
export function updateStatus (parameter) {
  return axios({
    url: api.sysBusinessInfo + `/updateStatus/${parameter.id}`,
    method: 'post',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}
export function unList (parameter) {
  return axios({
    url: api.sysBusinessInfo + '/unList',
    method: 'get',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

export function delSysBusinessInfo (parameter) {
  return axios({
    url: api.sysBusinessInfo + `/remove/${parameter.ids}`,
    method: 'post'
  })
}

export const sysBusinessInfoExport = api.sysBusinessInfo + '/export'
// sysDealerInfo
export function getSysDealerInfoList (parameter) {
  return axios({
    url: api.sysDealerInfo + '/list',
    method: 'get',
    params: parameter
  })
}
export function saveSysDealerInfo (parameter) {
  return axios({
    url: api.sysDealerInfo + (parameter.id > 0 ? '/update' : '/save'),
    method: 'post',
    data: parameter,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}
export function delSysDealerInfo (parameter) {
  return axios({
    url: api.sysDealerInfo + '/remove',
    method: 'post',
    params: parameter
  })
}

export const sysDealerInfoExport = api.sysDealerInfo + '/export'
// sysDcarbrandClassifyConfig
export function getSysDcarbrandClassifyConfigList (parameter) {
  return axios({
    url: api.sysDcarbrandClassifyConfig + '/list',
    method: 'get',
    params: parameter
  })
}
export function saveSysDcarbrandClassifyConfig (parameter) {
  return axios({
    url: api.sysDcarbrandClassifyConfig + (parameter.id > 0 ? '/update' : '/save'),
    method: 'post',
    data: parameter,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}
export function delSysDcarbrandClassifyConfig (parameter) {
  return axios({
    url: api.sysDcarbrandClassifyConfig + '/remove',
    method: 'post',
    params: parameter
  })
}

export const sysDcarbrandClassifyConfigExport = api.sysDcarbrandClassifyConfig + '/export'
// sysInsuranceSchemeConfig
export function getSysInsuranceSchemeConfigList (parameter) {
  return axios({
    url: api.sysInsuranceSchemeConfig + '/list',
    method: 'get',
    params: parameter
  })
}
export function saveSysInsuranceSchemeConfig (parameter) {
  return axios({
    url: api.sysInsuranceSchemeConfig + (parameter.id > 0 ? '/update' : '/save'),
    method: 'post',
    data: parameter,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}
export function delSysInsuranceSchemeConfig (parameter) {
  return axios({
    url: api.sysInsuranceSchemeConfig + '/remove',
    method: 'post',
    params: parameter
  })
}

export const sysInsuranceSchemeConfigExport = api.sysInsuranceSchemeConfig + '/export'
// sysInsuranceDetails
export function getSysInsuranceDetailsList (parameter) {
  return axios({
    url: api.sysInsuranceDetails + '/list',
    method: 'get',
    params: parameter
  })
}
// 查询支付管理接口  payList
export function sysInsuranceDetailspayList (parameter) {
  return axios({
    url: api.sysInsuranceDetails + '/payList',
    method: 'get',
    params: parameter
  })
}
export function saveSysInsuranceDetails (parameter) {
  return axios({
    url: api.sysInsuranceDetails + (parameter.id > 0 ? '/update' : '/save'),
    method: 'post',
    data: parameter,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}
export function delSysInsuranceDetails (parameter) {
  return axios({
    url: api.sysInsuranceDetails + '/remove',
    method: 'post',
    params: parameter
  })
}
// 更新更新支付状态和支付时间

export function updatePayStatusAndPayTime (parameter) {
  return axios({
    url: api.sysInsuranceDetails + '/updatePayStatusAndPayTime',
    method: 'post',
    // params: parameter,
    data: parameter
  })
}

// 更新保单号和保单生效时间
export function updateLossPolicyAndInsuranceStartdate (parameter) {
  return axios({
    url: api.sysInsuranceDetails + '/updateLossPolicyAndInsuranceStartdate',
    method: 'post',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    },
    // params: parameter,
    // data: parameter
    data: QS.stringify(parameter, { allowDots: true })
  })
}
// 导出投保清单excel
export function sysInsuranceDetailsexport (parameter) {
  return axios({
    url: api.sysInsuranceDetails + '/export',
    method: 'post',
    params: parameter
  })
}
export const sysInsuranceDetailsExport = api.sysInsuranceDetails + '/export'
// sysInsuranceweekDetails
export function getSysInsuranceweekDetailsList (parameter) {
  return axios({
    url: api.sysInsuranceweekDetails + '/list',
    method: 'get',
    params: parameter
  })
}
export function saveSysInsuranceweekDetails (parameter) {
  return axios({
    url: api.sysInsuranceweekDetails + (parameter.id > 0 ? '/update' : '/save'),
    method: 'post',
    data: parameter,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}
export function delSysInsuranceweekDetails (parameter) {
  return axios({
    url: api.sysInsuranceweekDetails + '/remove',
    method: 'post',
    params: parameter
  })
}
// 判断协议按钮状态
export function updateAgreement (parameter) {
  return axios({
    url: api.sysBusinessInfo + `/updateAgreement/${parameter.id}`,
    method: 'post'
  })
}

// 查询保单号管理 /system/sysInsuranceDetails/list
export function sysInsuranceDetails (parameter) {
  return axios({
    url: api.sysInsuranceDetails + '/remove',
    method: 'post',
    params: parameter
  })
}
// 查询保单号管理 /system/sysInsuranceDetails/list
export function getSchemeName (parameter) {
  return axios({
    url: api.sysInsuranceSchemeConfig + `/getSchemeName`,
    method: 'post',
    data: {
      schemeName: parameter
    }
  })
}
export const sysInsuranceweekDetailsExport = api.sysInsuranceweekDetails + '/export'
